import pandas as pd
import numpy as np
import tqdm
import os
file_path = "data/gephi 复健.csv"
data = pd.read_csv(file_path)
target = [i for i in data["target"].to_list()]
source = [i for i in data["source"].to_list()]
all_user = list(set(target + source))
print("a total of {} users".format(len(all_user)))
adj_m = np.zeros((len(all_user), len(all_user)), dtype=np.int32)
for i in tqdm.tqdm(range(len(source))):
    adj_m[all_user.index(source[i])][all_user.index(target[i])] = 1
adj_m = adj_m.tolist()
adj_m.insert(0, all_user)
pd.DataFrame(adj_m).to_csv("adj_m_{}".format(os.path.basename(file_path)))